/*
 * testReduce.cpp
 *
 *  Created on: Mar 27, 2011
 *      Author: curt
 */

#include "Reduce.h"
#include "CUDA_vec.h"
#include "utility.h"
#include "Operations.h"


int main(int argc, char* argv[])
{
	typedef float V;
	int p = 5;
	int N = (1 << p);
	V * array = new V[N];
	for(int i=1; i<=N; i++)
		array[i-1] = i;

	plus<V> op;
	CUDA_vec<V> v(N);
	v.copyToDevice(array, N);

	V result = CUDA_reduce(v, op);
	printf("N: %d\n", N);
	printf("Computed result: %d\n",(int)result);

	printf("Actual result: %d\n", (N * (N+1))/2);

	V prod = v.dotProd(v);
	printf("Sum of sq: %d\n", (int)prod);
	printf("Actual result: %d\n", N*(N+1)*(2*N+1)/6);

	return 0;
}
